package com.ruoyi.gas.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.gas.domain.ScheduleRegister;
import com.ruoyi.gas.mapper.ScheduleRegisterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gas.mapper.GetInRecordMapper;
import com.ruoyi.gas.domain.GetInRecord;
import com.ruoyi.gas.service.IGetInRecordService;

/**
 * 进站记录
Service业务层处理
 *
 * @author h w
 * @date 2022-12-09
 */
@Service
public class GetInRecordServiceImpl implements IGetInRecordService
{
    @Autowired
    private GetInRecordMapper getInRecordMapper;

    @Autowired
    private ScheduleRegisterMapper scheduleRegisterMapper;

    /**
     * 查询进站记录

     *
     * @param getInId 进站记录
主键
     * @return 进站记录

     */
    @Override
    public GetInRecord selectGetInRecordByGetInId(Long getInId)
    {
        return getInRecordMapper.selectGetInRecordByGetInId(getInId);
    }

    /**
     * 查询进站记录
列表
     *
     * @param getInRecord 进站记录

     * @return 进站记录

     */
    @Override
    public List<GetInRecord> selectGetInRecordList(GetInRecord getInRecord)
    {
        return getInRecordMapper.selectGetInRecordList(getInRecord);
    }

    @Override
    public List<GetInRecord> selectGetInRecordRecentList(GetInRecord getInRecord) {
        return getInRecordMapper.selectGetInRecordRecentList(getInRecord);
    }

    /**
     * 新增进站记录

     *
     * @param getInRecord 进站记录

     * @return 结果
     */
    @Override
    public int insertGetInRecord(GetInRecord getInRecord)
    {
        if(getInRecord.getRegisterId() != null) {
            ScheduleRegister register = new ScheduleRegister();
            register.setRegisterId(getInRecord.getRegisterId());
            register.setStatus("1");
            scheduleRegisterMapper.updateScheduleRegister(register);
        }
        getInRecord.setCreateTime(DateUtils.getNowDate());
        return getInRecordMapper.insertGetInRecord(getInRecord);
    }

    /**
     * 修改进站记录

     *
     * @param getInRecord 进站记录

     * @return 结果
     */
    @Override
    public int updateGetInRecord(GetInRecord getInRecord)
    {
        getInRecord.setUpdateTime(DateUtils.getNowDate());
        return getInRecordMapper.updateGetInRecord(getInRecord);
    }

    /**
     * 批量删除进站记录

     *
     * @param getInIds 需要删除的进站记录
主键
     * @return 结果
     */
    @Override
    public int deleteGetInRecordByGetInIds(Long[] getInIds)
    {
        return getInRecordMapper.deleteGetInRecordByGetInIds(getInIds);
    }

    /**
     * 删除进站记录
信息
     *
     * @param getInId 进站记录
主键
     * @return 结果
     */
    @Override
    public int deleteGetInRecordByGetInId(Long getInId)
    {
        return getInRecordMapper.deleteGetInRecordByGetInId(getInId);
    }
}
